<template>
  <div class="login_block">
    <a-card class="login_card" style="width: 500px; height: 300px">
      <a-form-model
        :model="form"
        :label-col="labelCol"
        :wrapper-col="wrapperCol"
      >
        <a-form-model-item label="手机号">
          <a-input v-model="form.phone" />
        </a-form-model-item>

        <a-form-model-item label="密码">
          <a-input v-model="form.password" type="password" />
        </a-form-model-item>
        <a-form-model-item :wrapper-col="{ span: 14, offset: 4 }">
          <a-button type="primary" @click="login"> 登录 </a-button>
        </a-form-model-item>
      </a-form-model>
    </a-card>
  </div>
</template>

<script>
export default {
  name: "login",
  data() {
    return {
      labelCol: { span: 4 },
      wrapperCol: { span: 14 },
      form: {
        phone: "",
        password: "",
      },
    };
  },
  created() {},
  methods: {
    // 请求登录
    login() {
      this.$get("/login/cellphone", {
        phone: this.form.phone,
        password: this.form.password,
      }).then((data) => {
        console.log(data.data.profile.avatarUrl)
        if (data.status === 200) {
          this.$message.success("登录成功")
          localStorage.setItem('avatarUrl',data.data.profile.avatarUrl)
          localStorage.setItem('userId',data.data.account.id)
          this.$router.push({
              path: '/home',
          })
        }
      });
    },
  },
};
</script>

<style scoped lang="less">
.login_block {
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: row;
  align-content: center;
  justify-content: center;
}
.login_card {
  margin-top: 200px;
  padding: 50px 0 0 0;
}
</style>